/**
 * 
 */
package com.cwt_taxi_xa.constants;

import com.cwt_taxi_xa.util.AppLog;
import com.cwt_taxi_xa.util.ExceptionUtil;
import com.cwt_taxi_xa.util.Tools;


/**
 * @author wlh
 * 报警标志位
 * 西安出租生声语音识别报警信息
 */
public class ConstantsEvaluate {

	private static final String TAG = "ConstantsEvaluate";

	//	0	1:无故拒载
	private static int a0 = 0;
	//	1	1:故意绕路
	private static int a1 = 0;
	//	2	1:强行拼车
	private static int a2 = 0;
	//	3	1:不打表
	private static int a3 = 0;
	//	4	1:不按标准收费
	private static int a4 = 0;
	//	5	1:中断服务
	private static int a5 = 0;
	//	6	1:未按规范标准服务
	private static int a6 = 0;
	//	7	1:乘客投诉
	private static int a7 = 0;
	//	8	1:紧急报警
	private static int a8 = 0;
	//	9〜31		预留
	private static int a9 = 0;
	private static int a10 = 0;
	private static int a11 = 0;
	private static int a12 = 0;
	private static int a13 = 0;
	private static int a14 = 0;
	private static int a15 = 0;
	private static int a16 = 0;
	private static int a17 = 0;
	private static int a18 = 0;
	private static int a19 = 0;
	private static int a20 = 0;
	private static int a21 = 0;
	private static int a22 = 0;
	private static int a23 = 0;
	private static int a24 = 0;
	private static int a25 = 0;
	private static int a26 = 0;
	private static int a27 = 0;
	private static int a28 = 0;
	private static int a29 = 0;
	private static int a30 = 0;
	private static int a31 = 0;

	public static boolean openUpload() {
		if (a0 == 1 ||
			a1 == 1 ||
			a2 == 1 ||
			a3 == 1 ||
			a4 == 1 ||
			a5 == 1 ||
			a6 == 1 ||
			a7 == 1 ||
			a8 == 1) {
			return true;
		}
		return false;
	}

	/**
	 * 设置报警值
	 * @param i 设置报警项
	 * @param value 值
	 */
	public static void setEvaluateValue(int i,int value){
		switch (i) {
		case 0:
			a0=value;
			break;
		case 1:
			a1=value;
			break;
		case 2:
			a2=value;
			break;
		case 3:
			a3=value;
			break;
		case 4:
			a4=value;
			break;
		case 5:
			a5=value;
			break;
		case 6:
			a6=value;
			break;
		case 7:
			a7=value;
			break;
		case 8:
			a8=value;
			break;
		case 9:
			a9=value;
			break;
		case 10:
			a10=value;
			break;
		case 11:
			a11=value;
			break;
		case 12:
			a12=value;
			break;
		case 13:
			a13=value;
			break;
		case 14:
			a14=value;
			break;
		case 15:
			a15=value;
			break;
		case 16:
			a16=value;
			break;
		case 17:
			a17=value;
			break;
		case 18:
			a18=value;
			break;
		case 19:
			a19=value;
			break;
		case 20:
			a20=value;
			break;
		case 21:
			a21=value;
			break;
		case 22:
			a22=value;
			break;
		case 23:
			a23=value;
			break;
		case 24:
			a24=value;
			break;
		case 25:
			a25=value;
			break;
		case 26:
			a26=value;
			break;
		case 27:
			a27=value;
			break;
		case 28:
			a28=value;
			break;
		case 29:
			a29=value;
			break;
		case 30:
			a30=value;
			break;
		case 31:
			a31=value;
			break;

		default:
			break;
		}
	}

	/**
	 * 清除报警值
	 */
	public static void clearEvaluateValue(){
		a0 =0;
		a1 =0;
		a2 =0;
		a3 =0;
		a4 =0;
		a5 =0;
		a6 =0;
		a7 =0;
		a8 =0;
		a9 =0;
		a10 =0;
		a11 =0;
		a12 =0;
		a13 =0;
		a14 =0;
		a15 =0;
		a16 =0;
		a17 =0;
		a18 =0;
		a19 =0;
		a20 =0;
		a21 =0;
		a22 =0;
		a23 =0;
		a24 =0;
		a25 =0;
		a26 =0;
		a27 =0;
		a28 =0;
		a29 =0;
		a30 =0;
		a31 =0;
	}

	/**
	 * 获取标志位
	 * @return
	 */
	public static byte[] getEvaluatebyte(){

		byte[] evaluate = new byte[4];
		try {
			//31-24位
			StringBuffer evaluate0 = new StringBuffer();
			evaluate0.append(a31);
			evaluate0.append(a30);
			evaluate0.append(a29);
			evaluate0.append(a28);
			evaluate0.append(a27);
			evaluate0.append(a26);
			evaluate0.append(a25);
			evaluate0.append(a24);
			evaluate[0] = Tools.BitToByte(evaluate0.toString());

			//23-16位
			StringBuffer evaluate1 = new StringBuffer();
			evaluate1.append(a23);
			evaluate1.append(a22);
			evaluate1.append(a21);
			evaluate1.append(a20);
			evaluate1.append(a19);
			evaluate1.append(a18);
			evaluate1.append(a17);
			evaluate1.append(a16);
			evaluate[1] = Tools.BitToByte(evaluate1.toString());

			//15-8位
			StringBuffer evaluate2 = new StringBuffer();
			evaluate2.append(a15);
			evaluate2.append(a14);
			evaluate2.append(a13);
			evaluate2.append(a12);
			evaluate2.append(a11);
			evaluate2.append(a10);
			evaluate2.append(a9);
			evaluate2.append(a8);
			evaluate[2] = Tools.BitToByte(evaluate2.toString());

			//7-0位
			StringBuffer evaluate3 = new StringBuffer();
			evaluate3.append(a7);
			evaluate3.append(a6);
			evaluate3.append(a5);
			evaluate3.append(a4);
			evaluate3.append(a3);
			evaluate3.append(a2);
			evaluate3.append(a1);
//			AppLog.e("------------------------------a1:"+a1);
			evaluate3.append(a0);
//			AppLog.e("------------------------------a0:"+a0);
			evaluate[3] = Tools.BitToByte(evaluate3.toString());

			//清除报警
			//clearEvaluateValue();

		} catch (Exception e) {
			e.printStackTrace();
			AppLog.e(ExceptionUtil.getInfo(e));
		}
		return evaluate;
	}

}
